package matching.triple;

import matching.Restriction;
import matching.xml.MatchElements;
import ontology.Ontology;
import org.jdom.Element;
import org.semanticweb.owl.model.OWLClass;
import org.semanticweb.owl.model.OWLObjectProperty;

public class ObjectPropertyTriple extends PropertyTriple {
	
    OWLObjectProperty objProp;

    public ObjectPropertyTriple(OWLObjectProperty e, OWLClass c, Restriction r, Ontology onto) {
        super(r,c, onto);
        objProp=e;
    }

    @Override
    public boolean equals(Triple t) {
        // TODO Auto-generated method stub
        return false;
    }

    @Override
    public Object getElement() {
        return objProp;
    }

     @Override
    public String toString(){
        return "element:"+objProp+" context:"+context+" restriction:"+restriction;
    }

    public String[] toArray(){
        String r;
        if(restriction!=null){
            r=restriction.toString();
        }
        else{ r="";}
        return new String[]{objProp.toString(), context.toString(), r};
    }
    
    //TODO nao terminado
    public  Element toElementXML(String type){
        Element triple = new Element(type);
        triple.addContent(new Element(MatchElements.element).addContent(objProp.toString()));
        triple.addContent(new Element(MatchElements.context).addContent(context.toString()));
        if(restriction!=null){
            Element rest = new Element(MatchElements.restriction);
            rest.addContent(new Element(MatchElements.attribute).addContent(restriction.atributte.toString()));
            rest.addContent(new Element(MatchElements.value).addContent(restriction.value));
        }
        return triple;
    }

    public Ontology getOnto() {
        return onto;
    }
}
